<?php
	class FileCache{
		private $expire_time = 3600;

		private $path = './';

		public function __construct($path=''){
			if($path){
				$this->path = $path;
			}
		}

		public function set($key,$value,$expire=15552000){
			$key = md5($key); //设置索引值				
        	$value = serialize($value); //将数据序列化
        	$expire = ($expire == -1) ? $expire : (time() + $expire); //过期时间
        	$this->store($key,$value);
		}

		public function get($key){
			$filename = $this->path.md5($key);
			if(!file_exists($filename)){
				return false;
			}
			$value = unserialize(file_get_contents($filename));
			return $value;
		}

		public function delete($key){

		}
		public function store($filename,$content){
			if(!file_exists($this->path.$filename)){
				@mkdir($this->path,'0777',1);
			}
			file_put_contents($this->path.$filename,$content);
		}
	}
?>